package com.yunhe.authority.controller.company;

import com.yunhe.authority.domain.company.*;
import com.yunhe.authority.model.paymentInfo.IncreasePercentVO;
import com.yunhe.authority.service.company.PaymentInfoService;
import com.yunhe.common.exception.ArgumentErrorException;
import com.yunhe.common.model.ResultObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ClassName: PaymentInfoController
 * @Description:
 * @author: GongDaCheng
 * @Date: 15:56 2021/7/19
 */
@Api(value = "PaymentInfo", description = "缴费信息", tags = {"Model_PaymentInfo"})
@RequestMapping("/paymentInfo")
@RestController
public class PaymentInfoController {

    @Autowired
    PaymentInfoService paymentInfoService;

    @ApiOperation("保存企业物业费用信息")
    @RequestMapping(value = "/savePropertyCost", method = RequestMethod.POST)
    public ResponseEntity<ResultObject> savePropertyCost(@RequestParam(value = "companyId", required = true) Long companyId, @RequestBody PropertyCost propertyCost) throws ArgumentErrorException {
        PropertyCost save = paymentInfoService.savePropertyCost(companyId, propertyCost);
        return new ResponseEntity<>(new ResultObject<>(save), HttpStatus.OK);
    }

    @ApiOperation("根据企业id查询企业物业费用信息")
    @RequestMapping(value = "/getPropertyCostByCompanyId", method = RequestMethod.GET)
    public ResponseEntity<ResultObject> getPropertyCostByCompanyId(@RequestParam(value = "companyId", required = true) Long companyId) throws ArgumentErrorException {
        PropertyCost getByCompanyId = paymentInfoService.getPropertyCostByCompanyId(companyId);
        return new ResponseEntity<>(new ResultObject<>(getByCompanyId), HttpStatus.OK);
    }

    @ApiOperation("保存企业物业费用增幅比例")
    @RequestMapping(value = "/saveIncreasePercent", method = RequestMethod.POST)
    public ResponseEntity<ResultObject> saveIncreasePercent(@RequestParam(value = "companyId", required = true) Long companyId, @RequestBody IncreasePercentVO increasePercentVO){
        IncreasePercent save = paymentInfoService.saveIncreasePercent(companyId, increasePercentVO);
        return new ResponseEntity<>(new ResultObject<>(save), HttpStatus.OK);
    }

    @ApiOperation("根据企业id查询企业物业费用增幅比例")
    @RequestMapping(value = "/getIncreasePercentByCompanyId", method = RequestMethod.GET)
    public ResponseEntity<ResultObject> getIncreasePercentByCompanyId(@RequestParam(value = "companyId", required = true) Long companyId){
        IncreasePercentVO getByCompanyId = paymentInfoService.getIncreasePercentByCompanyId(companyId);
        return new ResponseEntity<>(new ResultObject<>(getByCompanyId), HttpStatus.OK);
    }

    @ApiOperation("保存企业水电缴费信息")
    @RequestMapping(value = "/saveWEC", method = RequestMethod.POST)
    public ResponseEntity<ResultObject> saveWEC(@RequestParam(value = "companyId", required = true) Long companyId, @RequestBody WaterElectricityCost waterElectricityCost){
        WaterElectricityCost wec = paymentInfoService.saveWEC(companyId, waterElectricityCost);
        return new ResponseEntity<>(new ResultObject<>(wec), HttpStatus.OK);
    }

    @ApiOperation("根据企业id查询企业水电缴费信息")
    @RequestMapping(value = "/getWECByCompanyId", method = RequestMethod.GET)
    public ResponseEntity<ResultObject> getWECByCompanyId(@RequestParam(value = "companyId", required = true) Long companyId) throws ArgumentErrorException {
        WaterElectricityCost getByCompanyId = paymentInfoService.getWECByCompanyId(companyId);
        return new ResponseEntity<>(new ResultObject<>(getByCompanyId), HttpStatus.OK);
    }

    @ApiOperation("保存企业其他费用信息")
    @RequestMapping(value = "/saveOtherCost", method = RequestMethod.POST)
    public ResponseEntity<ResultObject> saveOtherCost(@RequestParam(value = "companyId", required = true) Long companyId, @RequestBody OtherCost otherCost){
        OtherCost save = paymentInfoService.saveOtherCost(companyId, otherCost);
        return new ResponseEntity<>(new ResultObject<>(save), HttpStatus.OK);
    }

    @ApiOperation("根据企业id查询企业其他费用信息")
    @RequestMapping(value = "/getOtherCostByCompanyId", method = RequestMethod.GET)
    public ResponseEntity<ResultObject> getOtherCostByCompanyId(@RequestParam(value = "companyId", required = true) Long companyId) throws ArgumentErrorException {
        OtherCost getByCompanyId = paymentInfoService.getOtherCostByCompanyId(companyId);
        return new ResponseEntity<>(new ResultObject<>(getByCompanyId), HttpStatus.OK);
    }

    @ApiOperation("新增合同附件")
    @RequestMapping(value = "/createContract", method = RequestMethod.POST)
    public ResponseEntity<ResultObject> createContract(@RequestParam(value = "companyId", required = true) Long companyId, @RequestBody ContractAccessories contractAccessories){
        ContractAccessories createContractAccessories = paymentInfoService.createContract(companyId, contractAccessories);
        return new ResponseEntity<>(new ResultObject<>(createContractAccessories), HttpStatus.OK);
    }

    @ApiOperation("查看合同附件列表")
    @RequestMapping(value = "/getAllContract", method = RequestMethod.GET)
    public ResponseEntity<ResultObject> findAllContract(@RequestParam(value = "companyId", required = true) Long companyId){
        List<ContractAccessories> all = paymentInfoService.findAllContract(companyId);
        return new ResponseEntity<>(new ResultObject<>(all), HttpStatus.OK);
    }

    @ApiOperation("编辑合同附件")
    @RequestMapping(value = "/updateContract", method = RequestMethod.PUT)
    public ResponseEntity<ResultObject> updateContract(@RequestParam(value = "companyId", required = true) Long companyId, @RequestParam(value = "id", required = true) Long id, @RequestBody ContractAccessories contractAccessories){
        ContractAccessories update = paymentInfoService.updateContract(companyId, id, contractAccessories);
        return new ResponseEntity<>(new ResultObject<>(update), HttpStatus.OK);
    }

    @ApiOperation("删除合同附件")
    @RequestMapping(value = "/deleteContract", method = RequestMethod.DELETE)
    public ResponseEntity<ResultObject> deleteContract(@RequestParam(value = "id", required = true) Long id){
        paymentInfoService.deleteContract(id);
        return new ResponseEntity<>(new ResultObject<>(), HttpStatus.OK);
    }

}
